package com.jiaotong.smart.smartjiaotong.mapper.GreenWaveMapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jiaotong.smart.smartjiaotong.entity.GreenWave.GreenWave;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 袁雨森
 * 绿波带的mapper
 */
@Repository
public interface GreenWaveMapper extends BaseMapper<GreenWave> {

    @Select("select sum(1) from greenwaveinfo where status='1'")
    Integer getAllUsingBandNumber();

    @Select("select sum(1) from greenwaveinfo where status='0'")
    Integer getAllNotUsingBandNumber();

    @Insert("insert into greenwaveinfo\n" +
            "values (#{greenWaveId},#{greenWaveName},#{timeSlot}, #{beginTime}, #{endTime}, #{status})\n" +
            "on duplicate key update green_wave_name=#{greenWaveName},time_slot=#{timeSlot},begin_time=#{beginTime},end_time=#{endTime},status=#{status}")
    void addGreenWave(GreenWave greenWave);
}
